package com.example.locationtracking.view;

import android.content.Intent;
import android.util.Log;

import com.example.locationtracking.R;
import com.example.locationtracking.utils.Const;
import com.example.locationtracking.utils.LTUtils;

public class SplashActivity extends BaseActivity{

	@Override
	protected void initUI() {
		if(getIntent().getBooleanExtra(Const.EXIT_APP, false)){
			finish();
			return;
		}
		setContentView(R.layout.splash_activity);
		checkUserValid();
	}
	private void checkUserValid(){
		String userName = LTUtils.getValue(getApplicationContext(), Const.USER_NAME_KEY);
		
		if (userName.isEmpty()){
			Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
			
			startActivity(intent);
			
		}else{
			Intent intent = new Intent(getApplicationContext(), LoginPinActivity.class);
			Log.e("user_pin", userName);
			intent.putExtra(Const.USER_NAME_KEY,userName );
			startActivity(intent);
			
		}
		this.finish();
	}
}
